﻿using System;
using System.Data;
using Model;
using DBUtility;

namespace DAL
{
     /// <summary>
     /// 数据访问层DEV_STANDARD_BRAKE_DAL
     /// </summary>
     public class DEV_STANDARD_BRAKE_DAL
     {
         public DEV_STANDARD_BRAKE_DAL()
         {
         }


         /// <summary>
         /// 得到最大ID
         /// </summary>
         public int GetMax_ID(string p_strWhere)
         {
             int intResult = 0;
             string strSql = "select max(ID) as m from DEV_STANDARD_BRAKE";

             if(p_strWhere.Trim().Length > 0)
             {
                 strSql += " where " + p_strWhere;
             }

             DataTable dtTemp = new DataTable();
             DbHelper.GetTable(strSql, ref dtTemp);

             if(dtTemp.Rows.Count>0)
             {
                 if(dtTemp.Rows[0]["m"].ToString().Length>0)
                 {
                     intResult = dtTemp.Rows[0]["m"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["m"]);
                 }
             }

             dtTemp.Dispose();

             return intResult + 1;

          }

          /// <summary>
          /// 得到最大ID
          /// </summary>
          public int GetMax_ID()
          {
              return GetMax_ID("");
          }


          /// <summary>
          /// 判断数据是否存在
          /// </summary>
          public bool Exists(int intID)
          {
               bool bolResult = false;


               string strSql = "";
               strSql += "select count(1) as c from DEV_STANDARD_BRAKE";
               strSql += " where ";
               strSql += " ID='"+ intID +"'";

               DataTable dtTemp = new DataTable();
               DbHelper.GetTable(strSql, ref dtTemp);

               if (dtTemp.Rows.Count > 0)
               {
                   bolResult = Convert.ToInt32(dtTemp.Rows[0]["c"]) > 0;
               }

               dtTemp.Dispose();

               return bolResult;

          }

          /// <summary>
          /// 获取数据总记录数
          /// </summary>
          public int GetRecordCount(string p_strWhere)
          {
              int intResult=0;

              string strSql = "";
              strSql += "select count(1) as c from DEV_STANDARD_BRAKE";
              if(p_strWhere.Trim().Length > 0)
              {
                 strSql += " where " + p_strWhere;
              }

              DataTable dtTemp = new DataTable();
              DbHelper.GetTable(strSql, ref dtTemp);

              if(dtTemp.Rows.Count>0)
              {
                  intResult=Convert.ToInt32(dtTemp.Rows[0]["c"]);
              }

              dtTemp.Dispose();

              return intResult;
          }

          /// <summary>
          /// 获取数据总记录数
          /// </summary>
          public int GetRecordCount()
          {
              return GetRecordCount("");
          }

          /// <summary>
          /// 获取数据分页总数
           /// </summary>
          public int GetPageCount(string p_strWhere, int p_intPageSize)
          {
              int intResult=0;

              if(p_intPageSize > 0)
              {
                  int intRecordCount = GetRecordCount(p_strWhere);
                  intResult = Convert.ToInt32(Math.Truncate(Convert.ToDecimal(intRecordCount) / Convert.ToDecimal(p_intPageSize)));
                  if (intRecordCount > (intResult * p_intPageSize))
                  {
                       intResult++;
                  }
              }

              if(intResult == 0)
              {
                   intResult++;
              }
              return intResult;
           }

          /// <summary>
          /// 获取数据分页总数
          /// </summary>
          public int GetPageCount(int p_intPageSize)
          {
              return GetPageCount("", p_intPageSize);
          }

          /// <summary>
          /// 添加一条数据 SQL
          /// </summary>
          public string InsertSQL(DEV_STANDARD_BRAKE model)
          {
              string strFieldSQL = "";
              string strValueSQL = "";

              if(model.Changed("ID") == true && model.ID != null)
              {
                   strFieldSQL += ",ID";
                   strValueSQL += "," + model.ID + "";
              }

              if(model.Changed("SEARCH_CONDITION") == true && model.SEARCH_CONDITION != null)
              {
                   strFieldSQL += ",SEARCH_CONDITION";
                   strValueSQL += ",'" + model.SEARCH_CONDITION.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("ZXMC") == true && model.ZXMC != null)
              {
                   strFieldSQL += ",ZXMC";
                   strValueSQL += ",'" + model.ZXMC.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("QZZZLVXZBZ") == true && model.QZZZLVXZBZ != null)
              {
                   strFieldSQL += ",QZZZLVXZBZ";
                   strValueSQL += ",'" + model.QZZZLVXZBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZZZLVXZBZ") == true && model.HZZZLVXZBZ != null)
              {
                   strFieldSQL += ",HZZZLVXZBZ";
                   strValueSQL += ",'" + model.HZZZLVXZBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("QZZDLVBZ") == true && model.QZZDLVBZ != null)
              {
                   strFieldSQL += ",QZZDLVBZ";
                   strValueSQL += ",'" + model.QZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZZDLVBZ") == true && model.HZZDLVBZ != null)
              {
                   strFieldSQL += ",HZZDLVBZ";
                   strValueSQL += ",'" + model.HZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("JZZDLVBZ") == true && model.JZZDLVBZ != null)
              {
                   strFieldSQL += ",JZZDLVBZ";
                   strValueSQL += ",'" + model.JZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("PBHZZDLVBZ") == true && model.PBHZZDLVBZ != null)
              {
                   strFieldSQL += ",PBHZZDLVBZ";
                   strValueSQL += ",'" + model.PBHZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("QZBPHLVBZ") == true && model.QZBPHLVBZ != null)
              {
                   strFieldSQL += ",QZBPHLVBZ";
                   strValueSQL += ",'" + model.QZBPHLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZBPHLVBZDY60") == true && model.HZBPHLVBZDY60 != null)
              {
                   strFieldSQL += ",HZBPHLVBZDY60";
                   strValueSQL += ",'" + model.HZBPHLVBZDY60.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZBPHLVBZXY60") == true && model.HZBPHLVBZXY60 != null)
              {
                   strFieldSQL += ",HZBPHLVBZXY60";
                   strValueSQL += ",'" + model.HZBPHLVBZXY60.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("SZDLVBZ") == true && model.SZDLVBZ != null)
              {
                   strFieldSQL += ",SZDLVBZ";
                   strValueSQL += ",'" + model.SZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("ZCZDLVBZ") == true && model.ZCZDLVBZ != null)
              {
                   strFieldSQL += ",ZCZDLVBZ";
                   strValueSQL += ",'" + model.ZCZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("IS_SHOW") == true && model.IS_SHOW != null)
              {
                   strFieldSQL += ",IS_SHOW";
                   strValueSQL += "," + model.IS_SHOW + "";
              }

              if(model.Changed("AREA_NAME") == true && model.AREA_NAME != null)
              {
                   strFieldSQL += ",AREA_NAME";
                   strValueSQL += ",'" + model.AREA_NAME.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("UTYPE") == true && model.UTYPE != null)
              {
                   strFieldSQL += ",UTYPE";
                   strValueSQL += "," + model.UTYPE + "";
              }

              string strSql = "";
              strSql += "insert into DEV_STANDARD_BRAKE";
              strSql += "(";
              strSql += strFieldSQL.Substring(1);
              strSql += ")";
              strSql += " values";
              strSql += "(";
              strSql += strValueSQL.Substring(1);
              strSql += ")";

              return strSql;
          }

          /// <summary>
          /// 添加一条数据
          /// </summary>
          public bool Insert(DEV_STANDARD_BRAKE model)
          {
              return DbHelper.ExecuteSql(InsertSQL(model));
          }

          /// <summary>
          /// 修改一条数据 SQL
          /// </summary>
          public string UpdateSQL(DEV_STANDARD_BRAKE model,int intID)
          {
              string strUpdateSQL = "";

              if(model.Changed("ID") == true && model.ID != null)
              {
                  strUpdateSQL += ",ID=" + model.ID + "";
              }

              if(model.Changed("SEARCH_CONDITION") == true && model.SEARCH_CONDITION != null)
              {
                  strUpdateSQL += ",SEARCH_CONDITION='" + model.SEARCH_CONDITION.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("ZXMC") == true && model.ZXMC != null)
              {
                  strUpdateSQL += ",ZXMC='" + model.ZXMC.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("QZZZLVXZBZ") == true && model.QZZZLVXZBZ != null)
              {
                  strUpdateSQL += ",QZZZLVXZBZ='" + model.QZZZLVXZBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZZZLVXZBZ") == true && model.HZZZLVXZBZ != null)
              {
                  strUpdateSQL += ",HZZZLVXZBZ='" + model.HZZZLVXZBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("QZZDLVBZ") == true && model.QZZDLVBZ != null)
              {
                  strUpdateSQL += ",QZZDLVBZ='" + model.QZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZZDLVBZ") == true && model.HZZDLVBZ != null)
              {
                  strUpdateSQL += ",HZZDLVBZ='" + model.HZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("JZZDLVBZ") == true && model.JZZDLVBZ != null)
              {
                  strUpdateSQL += ",JZZDLVBZ='" + model.JZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("PBHZZDLVBZ") == true && model.PBHZZDLVBZ != null)
              {
                  strUpdateSQL += ",PBHZZDLVBZ='" + model.PBHZZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("QZBPHLVBZ") == true && model.QZBPHLVBZ != null)
              {
                  strUpdateSQL += ",QZBPHLVBZ='" + model.QZBPHLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZBPHLVBZDY60") == true && model.HZBPHLVBZDY60 != null)
              {
                  strUpdateSQL += ",HZBPHLVBZDY60='" + model.HZBPHLVBZDY60.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("HZBPHLVBZXY60") == true && model.HZBPHLVBZXY60 != null)
              {
                  strUpdateSQL += ",HZBPHLVBZXY60='" + model.HZBPHLVBZXY60.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("SZDLVBZ") == true && model.SZDLVBZ != null)
              {
                  strUpdateSQL += ",SZDLVBZ='" + model.SZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("ZCZDLVBZ") == true && model.ZCZDLVBZ != null)
              {
                  strUpdateSQL += ",ZCZDLVBZ='" + model.ZCZDLVBZ.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("IS_SHOW") == true && model.IS_SHOW != null)
              {
                  strUpdateSQL += ",IS_SHOW=" + model.IS_SHOW + "";
              }

              if(model.Changed("AREA_NAME") == true && model.AREA_NAME != null)
              {
                  strUpdateSQL += ",AREA_NAME='" + model.AREA_NAME.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("UTYPE") == true && model.UTYPE != null)
              {
                  strUpdateSQL += ",UTYPE=" + model.UTYPE + "";
              }

               string strSql = "";
               strSql += "update DEV_STANDARD_BRAKE set ";
               strSql += strUpdateSQL.Substring(1);
               strSql += " where ";
               strSql += " ID="+ intID +"";

               return strSql;
          }

          /// <summary>
          /// 修改一条数据
          /// </summary>
          public bool Update(DEV_STANDARD_BRAKE model, int intID)
          {
              return DbHelper.ExecuteSql(UpdateSQL(model, intID));
          }

          /// <summary>
          /// 修改一个集合 SQL
          /// </summary>
           public string UpdateRangeSQL(DEV_STANDARD_BRAKE model, string p_strWhere)
          {
               string strUpdateSQL = "";

               if(model.Changed("ID") == true && model.ID != null)
               {
                  strUpdateSQL += ",ID=" + model.ID + "";
               }

               if(model.Changed("SEARCH_CONDITION") == true && model.SEARCH_CONDITION != null)
               {
                  strUpdateSQL += ",SEARCH_CONDITION='" + model.SEARCH_CONDITION.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("ZXMC") == true && model.ZXMC != null)
               {
                  strUpdateSQL += ",ZXMC='" + model.ZXMC.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("QZZZLVXZBZ") == true && model.QZZZLVXZBZ != null)
               {
                  strUpdateSQL += ",QZZZLVXZBZ='" + model.QZZZLVXZBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("HZZZLVXZBZ") == true && model.HZZZLVXZBZ != null)
               {
                  strUpdateSQL += ",HZZZLVXZBZ='" + model.HZZZLVXZBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("QZZDLVBZ") == true && model.QZZDLVBZ != null)
               {
                  strUpdateSQL += ",QZZDLVBZ='" + model.QZZDLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("HZZDLVBZ") == true && model.HZZDLVBZ != null)
               {
                  strUpdateSQL += ",HZZDLVBZ='" + model.HZZDLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("JZZDLVBZ") == true && model.JZZDLVBZ != null)
               {
                  strUpdateSQL += ",JZZDLVBZ='" + model.JZZDLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("PBHZZDLVBZ") == true && model.PBHZZDLVBZ != null)
               {
                  strUpdateSQL += ",PBHZZDLVBZ='" + model.PBHZZDLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("QZBPHLVBZ") == true && model.QZBPHLVBZ != null)
               {
                  strUpdateSQL += ",QZBPHLVBZ='" + model.QZBPHLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("HZBPHLVBZDY60") == true && model.HZBPHLVBZDY60 != null)
               {
                  strUpdateSQL += ",HZBPHLVBZDY60='" + model.HZBPHLVBZDY60.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("HZBPHLVBZXY60") == true && model.HZBPHLVBZXY60 != null)
               {
                  strUpdateSQL += ",HZBPHLVBZXY60='" + model.HZBPHLVBZXY60.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("SZDLVBZ") == true && model.SZDLVBZ != null)
               {
                  strUpdateSQL += ",SZDLVBZ='" + model.SZDLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("ZCZDLVBZ") == true && model.ZCZDLVBZ != null)
               {
                  strUpdateSQL += ",ZCZDLVBZ='" + model.ZCZDLVBZ.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("IS_SHOW") == true && model.IS_SHOW != null)
               {
                  strUpdateSQL += ",IS_SHOW=" + model.IS_SHOW + "";
               }

               if(model.Changed("AREA_NAME") == true && model.AREA_NAME != null)
               {
                  strUpdateSQL += ",AREA_NAME='" + model.AREA_NAME.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("UTYPE") == true && model.UTYPE != null)
               {
                  strUpdateSQL += ",UTYPE=" + model.UTYPE + "";
               }

              string strSql = "";
              strSql += "update DEV_STANDARD_BRAKE set ";
              strSql += strUpdateSQL.Substring(1);
              strSql += " where " + p_strWhere;

              return strSql;
          }

          /// <summary>
          /// 修改一个集合
          /// </summary>
          public bool UpdateRange(DEV_STANDARD_BRAKE model, string p_strWhere)
          {
              return DbHelper.ExecuteSql(UpdateRangeSQL(model, p_strWhere));
          }

          /// <summary>
          /// 修改全部数据 SQL
          /// </summary>
          public string UpdateAllSQL(DEV_STANDARD_BRAKE model)
          {
              string strUpdateSQL = "";

                  strUpdateSQL += ",ID=" + model.ID + "";
                  strUpdateSQL += ",SEARCH_CONDITION='" + model.SEARCH_CONDITION.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",ZXMC='" + model.ZXMC.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",QZZZLVXZBZ='" + model.QZZZLVXZBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",HZZZLVXZBZ='" + model.HZZZLVXZBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",QZZDLVBZ='" + model.QZZDLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",HZZDLVBZ='" + model.HZZDLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",JZZDLVBZ='" + model.JZZDLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",PBHZZDLVBZ='" + model.PBHZZDLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",QZBPHLVBZ='" + model.QZBPHLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",HZBPHLVBZDY60='" + model.HZBPHLVBZDY60.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",HZBPHLVBZXY60='" + model.HZBPHLVBZXY60.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",SZDLVBZ='" + model.SZDLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",ZCZDLVBZ='" + model.ZCZDLVBZ.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",IS_SHOW=" + model.IS_SHOW + "";
                  strUpdateSQL += ",AREA_NAME='" + model.AREA_NAME.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",UTYPE=" + model.UTYPE + "";


               string strSql = "";
               strSql += "update DEV_STANDARD_BRAKE set ";
               strSql += strUpdateSQL.Substring(1);

               return strSql;

          }

          /// <summary>
          /// 修改全部数据
          /// </summary>
          public bool UpdateAll(DEV_STANDARD_BRAKE model)
          {
              return DbHelper.ExecuteSql(UpdateAllSQL(model));
          }

          /// <summary>
          /// 删除一条数据 SQL
          /// </summary>
          public string DeleteSQL(int intID)
          {
              string strSql = "";
              strSql += "delete from DEV_STANDARD_BRAKE";
              strSql += " where ";
               strSql += " ID="+ intID +"";

              return strSql;

          }

          /// <summary>
          /// 删除一条数据
          /// </summary>
          public bool Delete(int intID)
          {
              return DbHelper.ExecuteSql(DeleteSQL(intID));
          }

          /// <summary>
          /// 删除一个集合 SQL
          /// </summary>
          public string DeleteRangeSQL(string p_strWhere)
          {
              string strSql = "";
              strSql += "delete from DEV_STANDARD_BRAKE";
              strSql += " where " + p_strWhere;

              return strSql;
           }

          /// <summary>
          /// 删除一个集合
          /// </summary>
          public bool DeleteRange(string p_strWhere)
          {
              return DbHelper.ExecuteSql(DeleteRangeSQL(p_strWhere));
          }

          /// <summary>
          /// 删除全部 SQL
          /// </summary>
          public string DeleteAllSQL()
          {
              string strSql = "";
              strSql += "delete from DEV_STANDARD_BRAKE";

              return strSql;
           }

         /// <summary>
         /// 删除全部
         /// </summary>
         public bool DeleteAll()
         {
             return DbHelper.ExecuteSql(DeleteAllSQL());
         }

          /// <summary>
         /// 得到一个对象实体
         /// </summary>
         public DEV_STANDARD_BRAKE GetModel(int intID)
         {
             string strSql = "";
             strSql += "select * from DEV_STANDARD_BRAKE";
             strSql += " where ";
               strSql += " ID="+ intID +"";

             DataTable dtTemp = new DataTable();
             DbHelper.GetTable(strSql, ref dtTemp);

             DEV_STANDARD_BRAKE model = new DEV_STANDARD_BRAKE();

             if(dtTemp.Rows.Count>0)
             {
                 model = new DEV_STANDARD_BRAKE();

                 model.ID = dtTemp.Rows[0]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["ID"]);
                 model.SEARCH_CONDITION = dtTemp.Rows[0]["SEARCH_CONDITION"] == DBNull.Value ? "" : dtTemp.Rows[0]["SEARCH_CONDITION"].ToString();
                 model.ZXMC = dtTemp.Rows[0]["ZXMC"] == DBNull.Value ? "" : dtTemp.Rows[0]["ZXMC"].ToString();
                 model.QZZZLVXZBZ = dtTemp.Rows[0]["QZZZLVXZBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["QZZZLVXZBZ"].ToString();
                 model.HZZZLVXZBZ = dtTemp.Rows[0]["HZZZLVXZBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["HZZZLVXZBZ"].ToString();
                 model.QZZDLVBZ = dtTemp.Rows[0]["QZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["QZZDLVBZ"].ToString();
                 model.HZZDLVBZ = dtTemp.Rows[0]["HZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["HZZDLVBZ"].ToString();
                 model.JZZDLVBZ = dtTemp.Rows[0]["JZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["JZZDLVBZ"].ToString();
                 model.PBHZZDLVBZ = dtTemp.Rows[0]["PBHZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["PBHZZDLVBZ"].ToString();
                 model.QZBPHLVBZ = dtTemp.Rows[0]["QZBPHLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["QZBPHLVBZ"].ToString();
                 model.HZBPHLVBZDY60 = dtTemp.Rows[0]["HZBPHLVBZDY60"] == DBNull.Value ? "" : dtTemp.Rows[0]["HZBPHLVBZDY60"].ToString();
                 model.HZBPHLVBZXY60 = dtTemp.Rows[0]["HZBPHLVBZXY60"] == DBNull.Value ? "" : dtTemp.Rows[0]["HZBPHLVBZXY60"].ToString();
                 model.SZDLVBZ = dtTemp.Rows[0]["SZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["SZDLVBZ"].ToString();
                 model.ZCZDLVBZ = dtTemp.Rows[0]["ZCZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[0]["ZCZDLVBZ"].ToString();
                 model.IS_SHOW = dtTemp.Rows[0]["IS_SHOW"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["IS_SHOW"]);
                 model.AREA_NAME = dtTemp.Rows[0]["AREA_NAME"] == DBNull.Value ? "" : dtTemp.Rows[0]["AREA_NAME"].ToString();
                 model.UTYPE = dtTemp.Rows[0]["UTYPE"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["UTYPE"]);
             }

             dtTemp.Dispose();

             return model;
         }

         /// <summary>
         /// 得到一个对象实体
         /// </summary>
         public void GetModel(ref DataTable p_dtData, int intID)
         {
             p_dtData.Clear();

             string strSql = "";
             strSql += "select * from DEV_STANDARD_BRAKE";
             strSql += " where ";
               strSql += " ID="+ intID +"";

              DbHelper.GetTable(strSql, ref p_dtData);
         }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public DEV_STANDARD_BRAKE[] GetModelList(string p_strWhere, string p_strOrder, int p_intPageNumber, int p_intPageSize)
      {
          int m_intPageNumber = p_intPageNumber;
          int m_intPageCount = GetPageCount(p_strWhere, p_intPageSize);

          if((m_intPageNumber < 1) || (m_intPageNumber == 0))
          {
               m_intPageNumber = 1;
          }

          if(m_intPageNumber == -1)
          {
               m_intPageNumber = m_intPageCount;
          }

          if(m_intPageNumber > m_intPageCount)
          {
               m_intPageNumber = m_intPageCount;
          }

          string strSql = "";
          strSql += "select * from DEV_STANDARD_BRAKE";
          if(p_strWhere.Trim().Length > 0)
          {
               strSql += " where " + p_strWhere;
          }
          if(p_strOrder.Trim().Length > 0)
          {
               strSql += " order by " + p_strOrder;
          }

          DataTable dtTemp = new DataTable();

          if(p_intPageSize > 0)
          {
               DbHelper.GetTable(strSql, ref dtTemp, (m_intPageNumber-1)*p_intPageSize, p_intPageSize);
          }
          else
          {
               DbHelper.GetTable(strSql, ref dtTemp);
          }

          DEV_STANDARD_BRAKE[] arrModel=new DEV_STANDARD_BRAKE[dtTemp.Rows.Count];

          for(int N=0;N<dtTemp.Rows.Count;N++)
          {
               arrModel[N] = new DEV_STANDARD_BRAKE();

                 arrModel[N].ID = dtTemp.Rows[N]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["ID"]);
                 arrModel[N].SEARCH_CONDITION = dtTemp.Rows[N]["SEARCH_CONDITION"] == DBNull.Value ? "" : dtTemp.Rows[N]["SEARCH_CONDITION"].ToString();
                 arrModel[N].ZXMC = dtTemp.Rows[N]["ZXMC"] == DBNull.Value ? "" : dtTemp.Rows[N]["ZXMC"].ToString();
                 arrModel[N].QZZZLVXZBZ = dtTemp.Rows[N]["QZZZLVXZBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["QZZZLVXZBZ"].ToString();
                 arrModel[N].HZZZLVXZBZ = dtTemp.Rows[N]["HZZZLVXZBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["HZZZLVXZBZ"].ToString();
                 arrModel[N].QZZDLVBZ = dtTemp.Rows[N]["QZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["QZZDLVBZ"].ToString();
                 arrModel[N].HZZDLVBZ = dtTemp.Rows[N]["HZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["HZZDLVBZ"].ToString();
                 arrModel[N].JZZDLVBZ = dtTemp.Rows[N]["JZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["JZZDLVBZ"].ToString();
                 arrModel[N].PBHZZDLVBZ = dtTemp.Rows[N]["PBHZZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["PBHZZDLVBZ"].ToString();
                 arrModel[N].QZBPHLVBZ = dtTemp.Rows[N]["QZBPHLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["QZBPHLVBZ"].ToString();
                 arrModel[N].HZBPHLVBZDY60 = dtTemp.Rows[N]["HZBPHLVBZDY60"] == DBNull.Value ? "" : dtTemp.Rows[N]["HZBPHLVBZDY60"].ToString();
                 arrModel[N].HZBPHLVBZXY60 = dtTemp.Rows[N]["HZBPHLVBZXY60"] == DBNull.Value ? "" : dtTemp.Rows[N]["HZBPHLVBZXY60"].ToString();
                 arrModel[N].SZDLVBZ = dtTemp.Rows[N]["SZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["SZDLVBZ"].ToString();
                 arrModel[N].ZCZDLVBZ = dtTemp.Rows[N]["ZCZDLVBZ"] == DBNull.Value ? "" : dtTemp.Rows[N]["ZCZDLVBZ"].ToString();
                 arrModel[N].IS_SHOW = dtTemp.Rows[N]["IS_SHOW"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["IS_SHOW"]);
                 arrModel[N].AREA_NAME = dtTemp.Rows[N]["AREA_NAME"] == DBNull.Value ? "" : dtTemp.Rows[N]["AREA_NAME"].ToString();
                 arrModel[N].UTYPE = dtTemp.Rows[N]["UTYPE"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["UTYPE"]);
          }

          dtTemp.Dispose();

          return arrModel;
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public DEV_STANDARD_BRAKE[] GetModelList(string p_strWhere)
      {
          return GetModelList(p_strWhere, "", -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public DEV_STANDARD_BRAKE[] GetModelList(string p_strWhere, string p_strOrder)
      {
          return GetModelList(p_strWhere, p_strOrder, -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public DEV_STANDARD_BRAKE[] GetModelList(int p_intPageNumber, int p_intPageSize)
      {
          return GetModelList("", "", p_intPageNumber, p_intPageSize);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public DEV_STANDARD_BRAKE[] GetModelList(string p_strWhere, int p_intPageNumber, int p_intPageSize)
      {
          return GetModelList(p_strWhere, "", p_intPageNumber, p_intPageSize);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public DEV_STANDARD_BRAKE[] GetModelList()
      {
          return GetModelList("", "", -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public void GetModelList(ref DataTable p_dtData, string p_strWhere, string p_strOrder, int p_intPageNumber, int p_intPageSize)
      {
          p_dtData.Clear();

          int m_intPageNumber = p_intPageNumber;
          int m_intPageCount = GetPageCount(p_strWhere, p_intPageSize);

          if((m_intPageNumber < 1) || (m_intPageNumber == 0))
          {
              m_intPageNumber = 1;
          }

          if(m_intPageNumber == -1)
          {
              m_intPageNumber = m_intPageCount;
          }

          if(m_intPageNumber > m_intPageCount)
          {
              m_intPageNumber = m_intPageCount;
          }

          string strSql = "";
          strSql += "select * from DEV_STANDARD_BRAKE";
          if(p_strWhere.Trim().Length > 0)
          {
              strSql += " where " + p_strWhere;
          }
          if(p_strOrder.Trim().Length > 0)
          {
              strSql += " order by " + p_strOrder;
          }

          if(p_intPageSize > 0)
          {
              DbHelper.GetTable(strSql, ref p_dtData, (m_intPageNumber-1)*p_intPageSize, p_intPageSize);
          }
          else
          {
              DbHelper.GetTable(strSql, ref p_dtData);
          }
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere)
       {
           GetModelList(ref p_dtData, p_strWhere, "", -1, -1);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere, string p_strOrder)
       {
           GetModelList(ref p_dtData, p_strWhere, p_strOrder, -1, -1);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, int p_intPageNumber, int p_intPageSize)
       {
           GetModelList(ref p_dtData, "", "", p_intPageNumber, p_intPageSize);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere, int p_intPageNumber, int p_intPageSize)
       {
           GetModelList(ref p_dtData, p_strWhere, "", p_intPageNumber, p_intPageSize);
       }
       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData)
       {
           GetModelList(ref p_dtData, "", "", -1, -1);
       }
   }
}
